<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>中心医院医疗服务系统</title>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/yzr_style.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<style type="text/css">
ul, li {
	padding: 0px;
	margin: 0px;
	list-style: none;
}
</style>
</head>
<body class="easyui-layout">
	<script src="<c:url value="/js/jquery-migrate-1.1.0.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/jquery.jqprint-0.3.js"/>"></script>
	<script type="text/javascript">
	var editIndexLMB = undefined;
	//结束正在编辑的行
	function endEditingLMB(){
		if (editIndexLMB == undefined){return true}
		if ($('#lmb_hcx').datagrid('validateRow', editIndexLMB)){
			//$('#lmb_hcx').datagrid('endEdit', editIndexLMB);
			//couPlanDetail.cpdCId,couPlanDetail.cpdName,couPlanDetail.cpdSupName,couPlanDetail.cpdSupplier
			var ed = $('#lmb_hcx').datagrid('getEditor', {index:editIndexLMB,field:'couPlanDetail.cpdCId'});					
			var cpdCId = $(ed.target).combogrid('getValue');	
			var cpdName = $(ed.target).combogrid('getText');	
			console.log("cpdCId:"+cpdCId);		
			$('#lmb_hcx').datagrid('getRows')[editIndexLMB]['cpdName'] = cpdName;		
			var ed2 = $('#lmb_hcx').datagrid('getEditor', {index:editIndexLMB,field:'couPlanDetail.cpdSupplier'});					
			var supName = $(ed2.target).combogrid('getText');	
			console.log("supName:"+supName);
			$('#lmb_hcx').datagrid('getRows')[editIndexLMB]['cpdSupplieName'] = supName;
			$('#lmb_hcx').datagrid('endEdit', editIndexLMB);
			editIndexLMB = undefined;
			return true;
		} else {
			return false;
		}
	}
	//事件：单击单元格的事件
	function onClickCellLMB(index, field){
		if (editIndexLMB != index){
			if (endEditingLMB()){
				$('#lmb_hcx').datagrid('selectRow', index)
						.datagrid('beginEdit', index);
				var ed = $('#lmb_hcx').datagrid('getEditor', {index:index,field:field});
				alert(ed);
				if (ed){
					($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus();
				}
				editIndexLMB = index;
			} else {
				setTimeout(function(){
					$('#lmb_hcx').datagrid('selectRow', editIndexLMB);
				},0);
			}
		}
	}
	/*结束编辑，同步数据*/
	/*function onEndEditLMB(index, row){	
		var ed = $(this).datagrid('getEditor', {
			index: index,
			field: 'couPlanDetail.cpdName'
		});
		var ed2 = $(this).datagrid('getEditor', {
			index: index,
			field: 'couPlanDetail.cpdCId'
		});
		row['couPlanDetail.cpdName'] = $(ed.target).combobox('getText');	
		row['couPlanDetail.cpdCId'] = $(ed.target).combobox('getValue');
		
		var ed1 = $(this).datagrid('getEditor', {
			index: index,
			field: 'couPlanDetail.cpdSupName'
		});
		var ed3 = $(this).datagrid('getEditor', {
			index: index,
			field: 'couPlanDetail.cpdSupplier'
		});

		row['couPlanDetail.cpdSupName'] = $(ed1.target).combobox('getText');	
		row['couPlanDetail.cpdSupplier'] = $(ed1.target).combobox('getValue');
	}
	*/
	//添加行
	function appendLMB(){
		if (endEditingLMB()){
			$('#lmb_hcx').datagrid('appendRow',{'couPlanDetail.cpdCId': [],'couPlanDetail.cpdName': [], 'couPlanDetail.cpdNorms': [],'couPlanDetail.cpdNum': [],'couPlanDetail.cpdSupplier': [],'couPlanDetail.cpdMoney': []});
			editIndexLMB = $('#lmb_hcx').datagrid('getRows').length-1;
			$('#lmb_hcx').datagrid('selectRow', editIndexLMB)
					.datagrid('beginEdit', editIndexLMB);
		}
	}
	//删除行
	function removeitLMB(){
		if (editIndexLMB == undefined){return}
		$('#lmb_hcx').datagrid('cancelEdit', editIndexLMB)
				.datagrid('deleteRow', editIndexLMB);
		editIndexLMB = undefined;
		alert(editIndexLMB);
	}
	//应用
	function acceptLMB(){
		if (endEditingLMB()){
			//$('#lmb_hcx_plan').datagrid('acceptChanges');
			endEditingLMB();
		}
	}
	//撤消
	function rejectLMB(){
		$('#lmb_hcx').datagrid('rejectChanges');
		editIndexLMB = undefined;
	}

	//获取数据
	function getChangesLMB(){
		var rows = $('#lmb_hcx').datagrid('getChanges');
		alert(rows.length+' rows are changed!');
	}
	
	//提交采购计划
	function savePlanLMB(){
		//将datagrid中的数据行保存到隐式表单域中
		//1、获取新增的数据行
		var rows = $('#lmb_hcx').datagrid('getChanges');
		console.log(JSON.stringify(rows));
		
		//为每一行生成对应的隐藏表单域
		
		for(var i = 0; i < rows.length; i ++){
			generateHidden(rows[i], "CId", i);
			generateHidden(rows[i], "Norms", i);
			generateHidden(rows[i], "Num", i);
			generateHidden(rows[i], "Supplier", i);
			generateHidden(rows[i], "Money", i);
		}
		

		//提交表单
		var lmb_hc_plan = $("#lmb_hc_plan");
		lmb_hc_plan.form("submit", {
			success: function(v){
				$.messager.alert('提示', "提交成功");
				$(":hidden[x='y']").remove();
				//关闭窗口
				$('#lmb_win-add').window('close');
				//重新加载数据lmb_hcx
				$("#lmb-Curpurplan").datagrid("reload");
				$(this).form("clear");
				rejectLMB();	
			}				
		});
		
	}
	
	function generateHidden(row, name, i){
		var hc_plan = $("#lmb_hc_plan");
		//
		$("<input type='hidden' x='y'>")
			.attr("name", "couPlanDetail[" + i + ']' + '.cpd' + name)
			.val(row['couPlanDetail.cpd' + name])
			.appendTo(hc_plan);
	} 
  
	$(function(){
		$("#plan-add").linkbutton({onClick:function(){						
				$("#lmb_win-add").window("open");
				$("#lmb_hc_plan").form("clear");
				$('#lmb_hcx').datagrid('loadData', { total: 0, rows: [] }); 
		}});
		
		//打开采购计划详情的窗口
		$("#plan-queryXq").linkbutton({onClick: function(){
			var rows = $("#lmb-Curpurplan").datagrid("getSelections");
			if(rows.length == 1){
				$('#lmb_win-add_2').window({'title':"采购计划详情"});
				$('#lmb_win-add_2').window("open");	
				//初始化表单
				var cpPlanId = rows[0].cpPlanId;
				console.log(cpPlanId);
				$("#lmb_win-add_3").datagrid({
					url:'to_queryCurPurPlanDetailsByPage',
					method:'post',
					queryParams:{
						id:cpPlanId
					}
				});
			}else{
				$.messager.alert("提示","只能选择一条记录，您目前选择了"+ rows.length + "条!");
			}
		}});
		
		//批量删除
		//<a id="plan-delete" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">删除采购计划</a>
		/*$("#plan-delete").linkbutton({onClick: function(){
			$.messager.confirm("提示", "确定要删除吗？", function(v){
				if(v){
					//获取所有选中的编号
					var rows = $("#lmb-Curpurplan").datagrid("getSelections");
					//将编号保存到数组中
					var arr = [];
					for(var i = 0; i < rows.length; i ++){
						arr.push(rows[i].cpPlanId);
					}
					//用form提交
					$('<form>').form('submit', {
					    url:'to_deleteCurPurPlans',
					    onSubmit: function(param){
					    	param.list = arr;
					    },
					    success:function(data){
					    	var json = eval("(" + data + ")");
							$.messager.alert("提示", json.reason);	
							$("#lmb-Curpurplan").datagrid("reload");
					    }
					});
				}
			});
		}});*/
		
		//日期转换
		function lmb_todate(value){
            if(value){
				var date = new Date(value);  
                return date.toLocaleDateString();
			}
        }
		
		//查看计划明细-打印
		$("#plan-dyjh").linkbutton({onClick: function(){
			
			var rows = $("#lmb-Curpurplan").datagrid("getSelections");
			if(rows.length == 1){	  
				$('#lmb-hcjDet-window').window({'title': "打印采购计划"});
				$('#lmb-hcjDet-window').window("open");
				var cpPlanId = rows[0].cpPlanId;
				$.getJSON("to_queryCurPurPlan", {"cpPlanId": cpPlanId}, function(data){
					$("#lmb-hcjDet-cgbh").linkbutton({text: data.cpPlanId});
					$("#lmb-hcjDet-xmmc").linkbutton({text: data.cpPlanTitle});
					$("#lmb-hcjDet-zdr").linkbutton({text: data.mname});
					$("#lmb-hcjDet-zdsj").linkbutton({text: lmb_todate(data.cpPlanDate)});
					$("#lmb-hcjDet-spr").linkbutton({text: data.pname});
					$("#lmb-hcjDet-spzt").linkbutton({text: data.purchAutditState});
					/*if(data.purchAutditState=='待审核' || data.purchAutditState=='未通过'){
						$("#yzr-purchDet-spzt").css({'color': 'red'});
					}
					if(data.purchAutditState=='已通过'){
						$("#yzr-purchDet-spzt").css({'color': 'green'});
					}*/
					$("#lmb-hcjDet-spsj").linkbutton({text: lmb_todate(data.cpPlanApprovedate)});
					//$("#yzr-purchDet-cgzt").linkbutton({text: data.purchState});
					/*if(data.purchState=='未采购'){
						$("#yzr-purchDet-cgzt").css({'color': 'red'});
					}*/
				});	
				
				 //根据id查看详情	
				 $("#lmb-hcjDet-dg").datagrid({
					url:'to_queryCurPurPlanDetailsByPage',
					width: '100%',
					queryParams:{					
		    			cpPlanId: cpPlanId,
		    			page:1, 
		    			rows:10
					}
				});
			}else{
				$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
			}
		}});
		//打印
		/*function printdivLmb(printpage){ 
			//获得当前页面body里面的内容
			var bodyHtml = document.body.innerHTML;
			//把打印的内容填充
			document.body.innerHTML = printpage; 
			//打印
			window.print(); 
			//把body的内容还原
			document.body.innerHTML = bodyHtml; 
			return true;

		}*/
		//点击按钮打印
		/*$("#lmb-hcjDet-print").linkbutton({
			onClick: function(){
				var printpage = $('#lmb-hcjDet-printArea').html();
				printdivLmb(printpage);
			}
		});
		*/
		//<!-- lmb-hcjDet-printArea, lmb_hcjDet_form-->
		//点击按钮打印
		$("#lmb-hcjDet-print").linkbutton({
			onClick: function(){
				$("#lmb-hcjDet-printArea").jqprint();
			}
		});
		
		//查找待审批的采购单
		 $("#plan-dsp").linkbutton({onClick: function(){
			 $("#lmb-Curpurplan").datagrid({
					url:'to_queryCurPurPlanByStatus',
					method:'post',
					queryParams:{
						status:'待审批',
				    	page:1, 
				    	rows:10
					}
				});
		 	}
		});	
		
		//查找已审批的采购单
		 $("#plan-ysp").linkbutton({onClick: function(){
			 $("#lmb-Curpurplan").datagrid({
					url:'to_queryCurPurPlanByStatus',
					method:'post',
					queryParams:{
						status:'已审批',
				    	page:1, 
				    	rows:10
					}
				});
		 	}
		});	
		
		//根据条件搜索
			$('#plan-search').searchbox({
			    searcher:function(value,name){
			    	$("#lmb-Curpurplan").datagrid({	    					
			    		url: name == 'title' ? 'to_queryCurPurPlanByTitle' : 'to_queryCurpurByPurstatus',
			    		method: 'post', 
			    		queryParams: {
			    			shuxing: value,
			    			page:1, 
					    	rows:10
			    	}});
			    }
			
			}); 
		
			// 刷新
			$("#plan-sx").linkbutton({onClick:function(){
				$("#lmb-Curpurplan").datagrid({
		    		url: 'to_queryCurPurPlanByPage', 
		    		method: 'get'
		    	});
			}});
			
			//<!-- cpPlanId, cpPlanTitle,cpPlanMakepeople,cpPlanApprovepeople,cpPlanDate -->
			//打开编辑采购计划窗口
			$("#plan-edit").linkbutton({onClick: function(){
				var rows = $("#lmb-Curpurplan").datagrid("getSelections");
				if(rows.length == 1){
					if(rows[0].cpPlanPurstatus!='已采购'){
						$('#lmb_win_cajh-edit').window({'title': "编辑采购计划"});
						$('#lmb_win_cajh-edit').window("open");
						var cpPlanId = rows[0].cpPlanId;
						//<!-- lmb_edit_chjh_jhdh(textbox),lmb_edit_chjh_xmmc(easyui-textbox),cpPlanMakepeople(combogrid), lmb_edit_chjh_spr(combogrid),lmb_edit_chjh_zdrq()-->
						$.getJSON("to_queryCurPurPlan", {"cpPlanId": cpPlanId}, function(data){
							$("#lmb_edit_chjh_jhdh").textbox("setValue",data.cpPlanId);
							$("#lmb_edit_chjh_xmmc").textbox("setValue",data.cpPlanTitle);
							$("#lmb_edit_chjh_zdr").combogrid("setValue",data.cpPlanMakepeople);
							$("#lmb_edit_chjh_spr").combogrid("setValue",data.cpPlanApprovepeople);//制定日期
							$("#lmb_edit_chjh_zdrq").datebox("setValue", lmb_todate(data.cpPlanDate));//预计到货日期 				
						});	
						
						 //根据id查看详情	lmb_hcx_edit_dg
						 $("#lmb_hcx_edit_dg").datagrid({
							url:'to_queryCurPurPlanDetailsByPage',
							queryParams:{
								cpPlanId: cpPlanId,
				    			page:1, 
				    			rows:10
							}
						});
					}else{
						$.messager.confirm("提示", "以采购的订单不能进行修改，是否查询详情？", function(v){
							if(v){
								$('#lmb-hcjDet-window').window({'title': "打印采购计划"});
								$('#lmb-hcjDet-window').window("open");
								var cpPlanId = rows[0].cpPlanId;
								$.getJSON("to_queryCurPurPlan", {"cpPlanId": cpPlanId}, function(data){
									$("#lmb-hcjDet-cgbh").linkbutton({text: data.cpPlanId});
									$("#lmb-hcjDet-xmmc").linkbutton({text: data.cpPlanTitle});
									$("#lmb-hcjDet-zdr").linkbutton({text: data.mname});
									$("#lmb-hcjDet-zdsj").linkbutton({text: lmb_todate(data.cpPlanDate)});
									$("#lmb-hcjDet-spr").linkbutton({text: data.pname});
									$("#lmb-hcjDet-spzt").linkbutton({text: data.purchAutditState});
									/*if(data.purchAutditState=='待审核' || data.purchAutditState=='未通过'){
										$("#yzr-purchDet-spzt").css({'color': 'red'});
									}
									if(data.purchAutditState=='已通过'){
										$("#yzr-purchDet-spzt").css({'color': 'green'});
									}*/
									$("#lmb-hcjDet-spsj").linkbutton({text: lmb_todate(data.cpPlanApprovedate)});
									//$("#yzr-purchDet-cgzt").linkbutton({text: data.purchState});
									/*if(data.purchState=='未采购'){
										$("#yzr-purchDet-cgzt").css({'color': 'red'});
									}*/
								});	
								
								 //根据id查看详情	
								 $("#lmb-hcjDet-dg").datagrid({
									url:'to_queryCurPurPlanDetailsByPage',
									width: '100%',
									queryParams:{					
						    			cpPlanId: cpPlanId,
						    			page:1, 
						    			rows:10
									}
								});
							}
							
						});
					}					
				}else{
					$.messager.alert("提示", "请选择一条记录!");
				}
			}});
			
			//关闭编辑窗口，刷新
			$("#lmb-editCouPurPlan-close").linkbutton({onClick: function(){
				$(":hidden[x='y']").remove();
				$('#lmb_hc_plan_edit').form("clear");
				reject_lmb_editcouPurPlan();
				$('#lmb_win_cajh-edit').window('close');
				$("#lmb-Curpurplan").datagrid("reload");
			}});
	});
	
	
</script>
<!-- 编辑 -->	 
	<script type="text/javascript">

		var editIndex_couPurPlan = undefined;
		
		//结束编辑行
		function endEditing_couPurPlan(){
			
			if (editIndex_couPurPlan == undefined){return true}
			
			if ($('#lmb_hcx_edit_dg').datagrid('validateRow', editIndex_couPurPlan)){
				
				//给耗材名赋值
				var ed = $('#lmb_hcx_edit_dg').datagrid('getEditor', {index:editIndex_couPurPlan,field:'cpdCId'});					
				var cpdName = $(ed.target).combogrid('getText');			
				$('#lmb_hcx_edit_dg').datagrid('getRows')[editIndex_couPurPlan]['cpdName'] = cpdName;
				
				
				//给供应商名赋值
				var ed2 = $('#lmb_hcx_edit_dg').datagrid('getEditor', {index:editIndex_couPurPlan,field:'cpdSupplier'});					
				var gname = $(ed2.target).combogrid('getText');	
				$('#lmb_hcx_edit_dg').datagrid('getRows')[editIndex_couPurPlan]['gname'] = gname;
					
				$('#lmb_hcx_edit_dg').datagrid('endEdit', editIndex_couPurPlan);			
				editIndex_couPurPlan = undefined;
				
				
				return true;
			} else {
				return false;
			}
		}
		
		//单击行
		function onClickRow_lmb_editcouPurPlan(index, field){
			
			if (editIndex_couPurPlan != index){
				
				if (endEditing_couPurPlan()){			
					$('#lmb_hcx_edit_dg').datagrid('selectRow', index).datagrid('beginEdit', index);								
					editIndex_couPurPlan = index;
					
				} else {			
					$('#lmb_hcx_edit_dg').datagrid('selectRow', editIndex_couPurPlan);
				}
			}
		}

		//添加行
		//cpdId,cpdCId,cpdName,cpdNorms,cpdNum,cpdSupplier,cpdMoney
		function append_lmb_editcouPurPlan(){
			if (endEditing_couPurPlan()){
				$('#lmb_hcx_edit_dg').datagrid('appendRow',{
					'cpdId': [],'cpdCId': [], 
					'cpdNorms': [], 'cpdNum': [],
					'cpdSupplier': [],'cpdMoney': []}); 
				
				
				editIndex_couPurPlan = $('#lmb_hcx_edit_dg').datagrid('getRows').length-1;
				$('#lmb_hcx_edit_dg').datagrid('selectRow', editIndex_couPurPlan)
						.datagrid('beginEdit', editIndex_couPurPlan);
			}
		}
		
		//移除一行
		function removeit_lmb_editcouPurPlan(){
			
			if (editIndex_couPurPlan == undefined){return}
			
			$('#lmb_hcx_edit_dg').datagrid('cancelEdit', editIndex_couPurPlan)
					.datagrid('deleteRow', editIndex_couPurPlan);
			
			editIndex_couPurPlan = undefined;
		}

		//应用
		function accept_lmb_editcouPurPlan(){
			if (endEditing_couPurPlan()){
				$('#lmb_hcx_edit_dg').datagrid('acceptChanges');
			}
		}

		
		//撤销
		function reject_lmb_editcouPurPlan(){
			$('#lmb_hcx_edit_dg').datagrid('rejectChanges');
			editIndex_couPurPlan = undefined;
		}
		
		//提交修改采购计划
		function saveCouPurPlanLmb(){
			
			var rows = $('#lmb_hcx_edit_dg').datagrid('getRows');		
			console.log(JSON.stringify(rows));
			//cpdId,cpdCId,cpdNorms,cpdNum,cpdSupplier,cpdMoney
			for(var i = 0; i < rows.length; i ++){
				generateHiddenLmb_edit(rows[i], "cpdId", i);
				generateHiddenLmb_edit(rows[i], "cpdCpPlanId", i);
				generateHiddenLmb_edit(rows[i], "cpdCId", i);
				generateHiddenLmb_edit(rows[i], "cpdName", i);
				generateHiddenLmb_edit(rows[i], "cpdNorms", i);
				generateHiddenLmb_edit(rows[i], "cpdNum", i);
				generateHiddenLmb_edit(rows[i], "cpdSupplier", i);
				generateHiddenLmb_edit(rows[i], "cpdMoney", i);
			}
			
			var hc_plan_edit = $("#lmb_hc_plan_edit");
				hc_plan_edit.form("submit", {
			
				url: 'to_lmb_editCouPurPlan',
				onSubmit: function(){
			    	return $(this).form("validate");
			    },
			    
				success: function(v){
					$.messager.alert('提示', "提交成功");
					$(":hidden[x='y']").remove();			
					$('#lmb_hc_plan_edit').form("clear");
					reject_lmb_editcouPurPlan();
					$('#lmb_win_cajh-edit').window('close');
					$("#lmb-Curpurplan").datagrid("reload");
				}
			});
		}
		
		
		//name=medPurchDets[0] .属性名称
		//value = row[属性名称]
		//创建隐式表单域来保存明细
		function generateHiddenLmb_edit(row, name, i){
			var ff_plan = $("#lmb_hc_plan_edit");
			//
			$("<input type='hidden' x='y'>")
				.attr("name", "couPlanDetail[" + i + '].'  + name)
				.val(row[name])
				.appendTo(ff_plan);
		}
		

	</script>

		<table id="lmb-Curpurplan" class="easyui-datagrid" data-options="
			url:'to_queryCurPurPlanByPage',
			fitColumns:true,fit:true,
			pagination: true,
			pageSize: 5,
			pageList: [5, 10, 15, 20],
			rownumbers: true,
			toolbar: '#lmb—hc_plan',
			border:false
			">
		<thead>
			<tr>
				<th data-options="field:'',checkbox:true"></th>
				<th data-options="field:'cpPlanId',width:'15%'">采购计划单号</th>
				<th data-options="field:'cpPlanTitle',width:'14%'">项目名称</th>
				<th data-options="field:'mname',width:'10%'">制定人</th>
				<th data-options="field:'cpPlanDate', width:'10%',
						formatter:function(value){
                          if(value){
							var date = new Date(value);  
                            return date.toLocaleDateString();
						  }
                 }">制定日期</th>
				<th data-options="field:'pname',width:'10%'">审批人</th>						
				<th data-options="field:'cpPlanStatus',width:'10%'">审批状态</th>	
				<th data-options="field:'cpPlanApprovedate', width:'10%',
						formatter:function(value){
						if(value){
							var date = new Date(value);  
                            return date.toLocaleDateString();
						}
                            
                 }">审批时间</th>
                 <th data-options="field:'cpPlanAppresult', width:'10%'">审批结果</th>
                 <th data-options="field:'cpPlanPurstatus', width:'10%'">采购状态</th>
			</tr>
		</thead>
	</table>
	
	<div id="lmb—hc_plan">
		<a id="plan-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加采购计划</a>
		<a id="plan-edit" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改采购计划</a>
		<a id="plan-dyjh" class="easyui-linkbutton" data-options="iconCls:'icon-xiangqing',plain:true">计划详情</a>
		<a id="plan-dsp" class="easyui-linkbutton" data-options="iconCls:'icon-dsp',plain:true">待审批</a>	
		<a id="plan-ysp" class="easyui-linkbutton" data-options="iconCls:'icon-ysp',plain:true">已审批</a>
		<!-- 
			<a id="plan-wdjh" class="easyui-linkbutton" data-options="iconCls:'icon-my',plain:true">我的计划</a>
			<a id="plan-dsp" class="easyui-linkbutton" data-options="iconCls:'icon-dsp',plain:true">待审批</a>	
			<a id="plan-ysp" class="easyui-linkbutton" data-options="iconCls:'icon-ysp',plain:true">已审批</a>
		 -->
		<a id="plan-sx" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
		<input id="plan-search" class="easyui-searchbox" data-options="menu: '#lmb-hcj-mm', width: 250, prompt: '请输入要查询的内容'"/>
	</div> 
	
	<!-- 搜索栏 -->
	<div id="lmb-hcj-mm" style="width:120px">
	    <div data-options="name:'title'">项目名称</div>
	     <div data-options="name:'purstatus'">采购状态</div>
	</div>
	
	<div id="lmb_win-add" class="easyui-window" title="录入采购计划" data-options="collapsible:true,minimizable:false,maximizable:true,modal:true,iconCls:'icon-save',closed: true" style="width:800px;height:320px;padding:5px;">
		<form id="lmb_hc_plan" action="to_lmb_doPlan" method="post">
			<table width="100%" style="background: rgb(236,243,255); padding: 10px; border-radius: 5px;">
				<tr>
					<td width="50%">
						<input id="cpt" class="easyui-textbox" name="coulPurlPlan.cpPlanTitle"
							data-options="label:'项目名称',width:'80%',required:true"/>
					</td>
					<td width="50%">
						<select id="cpm" name="coulPurlPlan.cpPlanMakepeople" class="easyui-combogrid" 
							    data-options="
							    required:true,
							    label: '制定人',							  
							    width:'88%',
							    panelWidth:288,
							    required:true,
							    url: 'queryAllStaff',
								pagination: true,
								pageSize: 8,
								pageList: [8, 16, 24, 32],
								idField: 'staffNo',
								textField: 'staffName',
								columns: [[
									{field:'staffName',title:'姓名',width:100},
									{field:'departmentName',title:'部门',width:100},
									{field:'postName',title:'职务',width:85}
								]]
						"></select>
					</td>
						
				</tr>
				<tr>
					<td>
						<select id="cpa"class="easyui-combogrid" name="coulPurlPlan.cpPlanApprovepeople"
						data-options="
								required:true,
								label:'审批人',
								width:'88%',
								panelWidth:288,
								required:true,
							    url: 'queryAllStaff',
								pagination: true,
								pageSize: 8,
								pageList: [8, 16, 24, 32],
								idField: 'staffNo',
								textField: 'staffName',
								columns: [[
									{field:'staffName',title:'姓名',width:100},
									{field:'departmentName',title:'部门',width:100},
									{field:'postName',title:'职务',width:85}
								]]										
						"></select>
						
					</td>
					
					<td>
						<input id="cpd"class="easyui-datebox" name="coulPurlPlan.cpPlanDate"
							data-options="label:'制定日期',width:'60%',required:true">
					</td>	
				</tr>
				<!-- 
					<tr>
						
						<td>
							<input id="cpd"class="easyui-datebox" name="coulPurlPlan.cpPlanDate"
							data-options="label:'预计到货日期',width:'60%'">
						</td>
					</tr> 
				-->
			</table>
			<div style="margin: 5px;">
				<div id="lmb_hcx_plan" class="easyui-tabs" style="width:100%;margin-top:10px;"
					data-options="plain:true,narrow:true">
					<div id="lmb_hcx_plan_1" title="采购计划明细" style="padding:10px">
						<table id="lmb_hcx" class="easyui-datagrid" style="height:auto"
							data-options="
								iconCls:'icon-edit',
								singleSelect: true,
								toolbar: '#lmb_tb1',
								method: 'get',
								onClickCell: onClickCellLMB,
								
								width: '100%'
							">
							<thead>
								<tr>
									<!-- <th data-options="field:'couPlanDetail.cpdCId/couPlanDetail.cpdName',width:'15%',editor:'textbox'">耗材ID</th> -->
									<th data-options="field:'couPlanDetail.cpdCId',width:'30%',
										formatter:function(value,row){
											return row.cpdName;
										},
										editor:{
											type:'combogrid',
											required:true,
											options:{	
												required:true,						
												url:'to_findConsumable',			
												idField: 'cId',
												textField: 'cName',
												panelWidth: '245',
												panelHeight: 'auto',
												columns: [[
													{field:'cId',title:'耗材编号',width:120},
													{field:'cName',title:'耗材名称',width:120},
												]]
											}
									}">耗材名称</th>

									<th data-options="field:'couPlanDetail.cpdNorms',width:'15%',editor:{
											type:'combobox',	
											options:{
												required:true,
												valueField:'label',
												textField:'value',
												panelHeight: 'auto',
												data: [
													{label:'包',value:'包'},
													{label:'卷',value:'卷'},
													{label:'个',value:'个'},
													{label:'双',value:'双'},
													{label:'袋',value:'袋'},
													{label:'瓶',value:'瓶'},
													{label:'箱',value:'箱'},
													{label:'片',value:'片'},
													{label:'支',value:'支'},
													{label:'板',value:'板'}
											]}
										}">单位</th>
									<th data-options="field:'couPlanDetail.cpdNum',width:'12%',required:true,editor:{type:'numberbox',options:{precision:0,required:true}}">数量</th>
									<!-- <th data-options="field:'couPlanDetail.cpdSupplier',width:'15%',editor:'textbox'">供应商ID</th> -->
									<th data-options="field:'couPlanDetail.cpdSupplier',width:'31%',
										formatter:function(value,row){
											return row.cpdSupplieName;
										},
										editor:{
											type:'combogrid',
											options:{
												required:true,
												url:'to_lmb_findSupplier',
												required:true,
												idField: 'supId',
												textField: 'supName',
												panelWidth: '257',
												panelHeight: 'auto',
												columns: [[
												{field:'supId',title:'供应商编号',width:125},
												{field:'supName',title:'供应商名称',width:130},
											]]
											}
										}">供应商</th>
									<th data-options="field:'couPlanDetail.cpdMoney',width:'13%',align:'center',required:true,editor:{
										type:'numberbox',
										options:{
											precision:0,
											required:true
										}
									}">预计金额</th>
								</tr>
							</thead>
						</table>
						<div id="lmb_tb1" style="height:auto">
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendLMB()">添加一行</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeitLMB()">移除一行</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" onclick="acceptLMB()">应用</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="rejectLMB()">撤销</a>
						</div>
					</div>				
				</div>	
				<div style="margin-top: 10px;">
					<a class="easyui-linkbutton" data-options="iconCls:'icon-ok', onClick: savePlanLMB">提交采购计划</a>				
				</div>			
			</div>
		</form>
	</div>
	

	<!--查看详情窗口-打印 -->
	<div id="lmb-hcjDet-window" class="easyui-window" title="采购计划详情" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:70%;height:70%;">		
		<div class="easyui-layout" style="padding:0px;" data-options="fit:true">			
			<div id="lmb-hcjDet-printArea" data-options="region:'center'" style="padding:5px;border-top:none;border-left:none;border-right:none;">			
				<form id="lmb_hcjDet_form" method="post">
					<h1 style="text-align: center">耗材采购计划</h1>
					<table width="100%">
						<tr>
						<!-- id="lmb-hcjDet-cgbh" data-options="field:'cpPlanId',width:'20%',align:'center'" -->
							<!-- <a id="lmb-hcjDet-cgbh" name="cpPlanId"     data-options="plain:true,"></a> -->
							<td>采购编号: <a id="lmb-hcjDet-cgbh" name="cpPlanId"     class="easyui-linkbutton" data-options="plain:true,"></a></td>
							<td>项目名称: <a id="lmb-hcjDet-xmmc" name="cpPlanTitle"  class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>制定人:  <a id="lmb-hcjDet-zdr"  name="mname"        class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>制定时间: <a id="lmb-hcjDet-zdsj" name="cpPlanDate"   class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
						<tr>
							<td>审批人:<a id="lmb-hcjDet-spr" name="pname" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<!-- <td>审批状态:<a id="lmb-hcjDet-spzt" name="cpPlanStatus" class="easyui-linkbutton" data-options="plain:true"></a></td> -->
							<td>审批时间:<a id="lmb-hcjDet-spsj" name="cpPlanApprovedate" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<!-- <td>采购状态:<a id="lmb-hcjDet-cgzt" name="" class="easyui-linkbutton" data-options="plain:true"></a></td> -->
						</tr>
					</table>
						
					<div style="margin: 5px;">
						<table id="lmb-hcjDet-dg" class="easyui-datagrid" 
							data-options="
								iconCls: 'icon-edit',
								singleSelect: true,										
								width: '100%'						
						">			
							<thead>
								<tr>	
									<th data-options="field:'cpdId',width:'20%',align:'center'">计划明细编号</th>	
									<th data-options="field:'cpdName',width:'21%',align:'center'">药品名称</th>					
									<th data-options="field:'cpdNorms',width:'13%',align:'center'">单位</th>
									<th data-options="field:'cpdNum',width:'13%',align:'center'">数量</th>
									<th data-options="field:'gname',width:'21%',align:'center'">供应商</th>
									<th data-options="field:'cpdMoney',width:'13%',align:'center'">预计金额</th>
								</tr>
							</thead>
						</table>									
					</div>
				</form>				
			</div>
					
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="lmb-hcjDet-print"  class="easyui-linkbutton" data-options="iconCls:'icon-print', plain:true">打印</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:$('#lmb-hcjDet-window').window('close');">取消</a>
			</div>			
		</div>
	</div>
	
	
	<!-- 修改窗口-->
	<div id="lmb_win_cajh-edit" class="easyui-window"  data-options="collapsible:true,minimizable:false,maximizable:true,modal:true,iconCls:'icon-save',closed: true" style="width:800px;height:320px;padding:5px;">
		<form id="lmb_hc_plan_edit"  method="post">
			<table width="100%" style="background: rgb(236,243,255); padding: 10px; border-radius: 5px;">
				<tr>
					<td width="33%">
						<input id="lmb_edit_chjh_jhdh" class="easyui-textbox" name="cpPlanId"
							data-options="label:'计划单号',width:'80%',required:true"/>
					</td>
					<td width="33%">
						<input id="lmb_edit_chjh_xmmc" class="easyui-textbox" name="cpPlanTitle"
							data-options="label:'项目名称',width:'80%',required:true"/>
					</td>
					<td width="33%">
						<select id="lmb_edit_chjh_zdr" name="cpPlanMakepeople" class="easyui-combogrid" 
							    data-options="
							    label: '制定人',							  
							    width:'90%',
							    panelWidth:264,
							    required:true,
							    idField:'staffNo',
							    textField:'staffName',
							    url:'queryAllStaff',
							    columns:[[					    
							    {field:'staffName',title:'姓名',width:89},
							    {field:'departmentName',title:'部门',width:89},
							    {field:'postName',title:'职务',width:84},
							    ]]	
						"></select>
					</td>
						
				</tr>
				<tr>
					<td>
						<select id="lmb_edit_chjh_spr"class="easyui-combogrid" name="cpPlanApprovepeople"
						data-options="
								label:'审批人',
								width:'90%',
								panelWidth:264,
								required:true,
							    idField:'staffNo',
							    textField:'staffName',
							    url:'queryAllStaff',
							    columns:[[					    
							    {field:'staffName',title:'姓名',width:89},
							    {field:'departmentName',title:'部门',width:89},
							    {field:'postName',title:'职务',width:84},
							    ]]			
								
						"></select>
					</td>	
					
					<td>
						<input id="lmb_edit_chjh_zdrq"class="easyui-datebox" name="cpPlanDate"
							data-options="label:'制定日期',width:'60%'">
					</td>
				</tr>
			</table>
			<div style="margin: 5px;">
				<div id="lmb_cgjhxq_plan_edit" class="easyui-tabs" style="width:100%;margin-top:10px;"
					data-options="plain:true,narrow:true">
					<div id="lmb_cgjhxq_plan_edit" title="采购计划明细" style="padding:10px">
						<table id="lmb_hcx_edit_dg" class="easyui-datagrid" style="height:auto"
							data-options="
								iconCls:'icon-edit',
								singleSelect: true,
								toolbar: '#lmb_tb3',
								onClickRow:onClickRow_lmb_editcouPurPlan,												
								method: 'get',						
								width: '100%'
							">
							<thead>
								<tr>
									<th data-options="field:'cpdId',width:'20%',editor:'textbox'">计划明细编号</th> 
									<th data-options="field:'cpdCId',width:'22%',
										formatter:function(value,row){
											return row.cpdName;
										},
										editor:{
											type:'combogrid',
											required:true,
											options:{	
												required:true,						
												url:'to_findConsumable',			
												idField: 'cId',
												textField: 'cName',
												panelWidth: '245',
												panelHeight: 'auto',
												columns: [[
													{field:'cId',title:'耗材编号',width:120},
													{field:'cName',title:'耗材名称',width:120},
												]]
											}
									}">耗材名称</th>
									<th data-options="field:'cpdNorms',width:'12%',editor:{
											type:'combobox',	
											options:{
												required:true,
												valueField:'label',
												textField:'value',
												panelHeight: 'auto',
												data: [{label:'箱',value:'箱'},{label:'盒',value:'盒'}]
											}
										}">单位</th>
									<th data-options="field:'cpdNum',width:'12%',required:true,editor:{type:'numberbox',options:{precision:0,required:true}}">数量</th>
									<th data-options="field:'cpdSupplier',width:'22%',
										formatter:function(value,row){
											return row.gname;
										},
										editor:{
											type:'combogrid',
											options:{
												required:true,
												url:'to_lmb_findSupplier',
												required:true,
												idField: 'supId',
												textField: 'supName',
												panelWidth: '257',
												panelHeight: 'auto',
												columns: [[
												{field:'supId',title:'供应商编号',width:125},
												{field:'supName',title:'供应商名称',width:130},
											]]
											}
										}">供应商</th>
									<th data-options="field:'cpdMoney',width:'12%',align:'center',required:true,editor:{
										type:'numberbox',
										options:{
											precision:2,
											required:true
										}
									}">预计金额</th>
								</tr>
							</thead>
						</table>			
						<div id="lmb_tb3" style="height:auto">
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append_lmb_editcouPurPlan()">添加一行</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit_lmb_editcouPurPlan()">移除一行</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" onclick="accept_lmb_editcouPurPlan()">应用</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject_lmb_editcouPurPlan()">撤销</a>
						</div>
					</div>				
				</div>	
				<div style="margin-top: 10px;">
					<a class="easyui-linkbutton" data-options="iconCls:'icon-ok', onClick: saveCouPurPlanLmb">保存计划</a>				
					<a id="lmb-editCouPurPlan-close" class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" >取消</a>
				</div>			
			</div>
		</form>
	</div>
</body>
</html>